home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 1.6 KB | 58 lines | [TEXT/GEOL] |
- Item forwarded by PERRY.G to PIRO
-
- Item 2982208 11-Sept-90 11:08PDT
-
- From: MM.XOBJ MacroMind, XObject Support,PRT
-
- To: CPLUS.DEV$ C++ Interest List--Developers
- CPLUS.APPLE$ C++ Interest List--Apple Employees
-
- Sub: inline virtuals
-
- Can anyone answer me this?
-
- I discovered my code suffered from the classic problem of overriding only one
- of two versions of a method, something like:
-
- class Foo {
- public:
- ....
- int doItWithA(char c);
- int doItWithA(float f);
- };
- class Bar : public Foo {
- public:
- ....
- int doItWithA(float);
- };
-
- Now I want to fix this problem, and the Lippmann book says the only way to make
- them all available (short of resorting to scope resolution operators) is to
- provide a definition for all of them. Naturally, I would like to do this
- without adding any overhead:
-
- class Bar: public Foo {
- public:
- ....
- int doItWithA(char c) {return Foo::doItWithA(c); }
- int doItWithA(float f);
- };
-
- The only problem is that (I saved this part for last), all of the mentioned
- methods are *virtual*. It seems to me there is a fundamental conflict between
- virtuals and inlines. I tried compiling this, and it seems OK, but I am still
- afraid I'll die and go to hell if use inline definitions of virtual functions.
-
- Can someone tell me how thin this ice is, and where it would break?
-
- Haim Zamir
- MacroMind, Inc.
- AppleLink MM.XOBJ
-
- P.S. Also does anyone know why the Compiler doesn't produce a warning when I
- hide multiple versions of a function with a single override?
-
-
-
-
-